<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('project_teams', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->default(0)->index();
            $table->unsignedBigInteger('admin_id')->default(0)->index();
            $table->unsignedBigInteger('project_id')->default(0)->index();
            $table->unsignedBigInteger('team_id')->default(0)->index();
            $table->string('scene')->nullable()->comment('现场负责人');
            $table->string('scene_mobile')->nullable()->comment('现场负责人电话');
            $table->string('scene_id_card')->nullable()->comment('现场负责人身份证号码');
            $table->string('scene_id_card_files')->nullable()->comment('现场负责人身份证复件');
            $table->decimal('daily_wage', 5, 2)->nullable()->comment('日薪');
            $table->time('in_time')->nullable()->comment('上班打卡时间');
            $table->time('out_time')->nullable()->comment('下班打卡时间');
            $table->smallInteger('in_flexible_minutes')->default(0)->comment('上班弹性时间（分钟）');
            $table->smallInteger('out_flexible_minutes')->default(0)->comment('下班弹性时间（分钟）');
            $table->smallInteger('late_threshold')->default(0)->comment('迟到阈值时间');
            $table->smallInteger('early_leave_threshold')->default(0)->comment('早退阈值时间');
            $table->string('remarks')->nullable()->comment('备注');
            $table->timestamps();
            $table->unique(['project_id', 'team_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('project_teams');
    }
};
